package atmGUI;


import util.Util;

import javax.swing.*;
import java.awt.*;

//ATM_GUI_Main
public class ATM_GUI_Main extends JFrame {
    private Image bgdImage = Util.getImage("/image/background.jpg");  //背景图
    private LoginPanel loginPanel = new LoginPanel(this);
    private MenuPanel menuPanel = new MenuPanel(this);
    private CardLayout cardLayout = new CardLayout();

    public ATM_GUI_Main() {
        //设置背景图
        this.setContentPane(new JPanel() {
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(bgdImage, 0, 0, 1024, 768, this);
            }
        });

        //设置卡牌布局
        setLayout(cardLayout);
        //添加卡牌
        this.add("login", loginPanel);
        this.add("menu", menuPanel);

        //设置窗口大小
        this.setSize(1024, 1024);
        //设置title
        this.setTitle("中国银行");
        //设置窗口点击关闭程序结束
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        //设置窗口可见
        this.setVisible(true);
    }

    public void switchPanel(String name) {
        cardLayout.show(this.getContentPane(), name);
    }

    //Main
    public static void main(String[] args) {
        new ATM_GUI_Main();
    }
}
